(function () {
    /**
     * 处理图片加载失败
     * @param img
     */
    function handleImageError(img) {
        const container = document.createElement('div');
        container.style.cssText = `
            width: ${img.width || 370}px;
            height: ${img.height || 210}px;
            background: #e1cbd5;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            border: 1px dashed #ddd;
        `;

        container.innerHTML = `
            <span style="font-size: 24px;">⚠️</span>
            <span style="font-size: 14px; color: #000000; margin-top: 8px">
                图片加载失败
            </span>
        `;

        img.parentNode.replaceChild(container, img);
    }

    window.handleImageError = handleImageError;
})(window.jQuery);